"""
@name : 05.装饰器带参数
@author : wenyao
@projectname: xsfh
"""
#自身不传入参数的装饰器，使用两层函数定义
#自身传入参数的装饰器，使用三层函数定义

import time
import functools

# def Time(func):
#     print("i am time")
#     #  保留传递进来的函数的元数据，将它的元数据赋值给inner
#     # 保留元数据
#     @functools.wraps(func)
#     def inner(*args,**kwargs):
#         start=time.time()
#         re=func(*args,**kwargs)
#         end=time.time()
#         print(f"共花费了{end-start}")
#         return re
#     return inner
def deco (name):
    def Time(func):
        def inner(*args,**kwargs):
            start=time.time()
            re=func(*args,**kwargs)
            end=time.time()
            print(f"共花费了{end-start}")
            print(f'name is {name}')
            return re
        return inner
    return Time

@deco(name = "root")  #Time = deco(name = "root") ; func1 = Time(func1)
#Time = deco(name = "root")
# func1 = Time(func1)
def func1():
    time.sleep(2)
    return "func1"

func1()